package com.xiaofu.live.id.generate.provider;


import com.xiaofu.live.id.generate.provider.service.IdBuilderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.HashSet;
import java.util.Set;

@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
@Slf4j
@MapperScan("com.xiaofu.live.id.generate.provider.dao")
public class IdGenerateProvider implements CommandLineRunner {

    @Autowired
    private IdBuilderService idBuilderService;

    @Override
    public void run(String... args) throws Exception {
        Set<Long> idSet = new HashSet<>();
        for (int i = 0; i < 1500; i++) {
            Long id = idBuilderService.increaseSeqId(1);
            idSet.add(id);
        }
        System.out.println(idSet.size());
    }

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(IdGenerateProvider.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);
    }
}
